<?php
namespace app\api\controller;

use app\api\model\Location;
use think\facade\Request;

class Index extends Controllers
{
    public function index()
    {
        $location = Location::order('id', 'desc')->paginate(20);
        $this->assign([
            'location' => $location,
            'page' => $location->render(),
        ]);
        return $this->fetch('index');
    }

    public function location()
    {
        $post = $this->request->post();
        Location::create([
            'lng' => $post['lng'],
            'lat' => $post['lat'],
            'addresses' => $post['addresses'],
            'http_user_agent' => Request::header('user-agent')
        ]);
    }

}
